(function($) {
  $.fn.downloadr = function(option) {
  	return this.each(function() {
  	
  	function returnBrowserTest(){
				
					var dlBrowser = $.browser.browser();
					
					var dlString = '';
					
					switch(dlBrowser){
					
						case "Safari":
						
						dlString = '点击右键选择 <strong>保存链接为...</strong> or <strong>下载链接文件为...</strong> from the menu.';
						
						break;
						
						case "Firefox":
						
						dlString = '点击右键选择 <strong>保存链接为...</strong> from the menu.'
						
						break;
						
						case "Msie":
						
						dlString = '点击右键选择 <strong>另存为...</strong>.';
						
						break;
						
						default:
						
						dlString = '点击右键选择 <strong>另存为...</strong> .';
					}
					
					
					return dlString;
				}	
				
				var element = this;
			  
			  	$(element).addClass("download_link");
			  	
			  	var theTitle = $(element).attr('title');
			  				  	
				var theLink = $(element).attr('href');
	
			  	$(element).bind('click',function(e){
			  	
			  		e.preventDefault();

				  	var html = "";
				  	
				  	html += "<h2>下载 '" + theTitle + "'</h2>";
				  	html += "<p>下载'" + theTitle + "',  " + returnBrowserTest() + "</p>";
				  	html += "<p style='text-align:center;'><a href='" + theLink + "'><img src='"+plugin+"/download/downloadr/download.png' width='50px' height='60px' alt='点击右键保存' id='download_file'/></a></p>";
				  	html += "<p>如果你想在浏览器中打开该文件，点击<strong><a href='" + theLink + "'>这里</a></strong>.</p>";
				  	open(option)
			  	});
			  	});

  }
  function open(option){
	  var url = option.url;
	  var title = "下载";
	  if(option.title){
		  title = option.title;
	  }
	  parent.layer.open({
		      type: 2,
			  content:url
			 ,title:title
		     ,area: [150, 120]
		     ,id:"downFormDialog"
		 });
  }
})(jQuery);